﻿using System;
using System.Windows.Media;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace WickedFlame.Core.Tools
{
    public delegate void ToolColorChangedDelegate(Brush brush);
	public delegate void FontFamilyChangedDelegate(FontFamily font);
    public delegate void FontSizeChangedDelegate(double fontSize);
	public delegate void StrokeThicknessChanged(double stroke);

	public class ShapePropertySettings : INotifyPropertyChanged
	{
		public event ToolColorChangedDelegate StrokeChanged;
		public event ToolColorChangedDelegate FillChanged;
		public event FontFamilyChangedDelegate FontFamilyChanged;
		public event FontSizeChangedDelegate FontSizeChanged;
		public event StrokeThicknessChanged StrokeThicknessChanged;

		#region INotifyPropertyChanged Members

		public event PropertyChangedEventHandler PropertyChanged;

		protected void NotifyPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		#endregion

		static ShapePropertySettings _settings;
		public static ShapePropertySettings Settings
		{
			get
			{
				if (_settings == null)
					_settings = new ShapePropertySettings();
				return _settings;
			}
		}

		/// <summary>
		/// Private constructor for settings
		/// </summary>
		private ShapePropertySettings() { }

		static ObservableCollection<double> _strokeThicknessCollection;
		public ObservableCollection<double> StrokeThicknessCollection
		{
			get
			{
				if (_strokeThicknessCollection == null)
				{
					_strokeThicknessCollection = new ObservableCollection<double>();
					for (int i = 0; i < 150; i++)
						_strokeThicknessCollection.Add(i);
				}
				return _strokeThicknessCollection;
			}
		}

		Brush _stroke = System.Windows.Media.Brushes.Black;
		public Brush Stroke
		{
			get
			{
				return _stroke;
			}
			set
			{
				_stroke = value;
                if (StrokeChanged != null)
                    StrokeChanged(_stroke);

				NotifyPropertyChanged("Stroke");
			}
		}
		
		double _strokeThickness = 1;
		public double StrokeThickness
		{
			get
			{
				return _strokeThickness;
			}
			set
			{
				_strokeThickness = value;
				if (StrokeThicknessChanged != null)
					StrokeThicknessChanged(value);

				NotifyPropertyChanged("StrokeThickness");
			}
		}

		Brush _fill = System.Windows.Media.Brushes.White;
		public Brush Fill
		{
			get
			{
				return _fill;
			}
			set
			{
				_fill = value;
                if (FillChanged != null)
                    FillChanged(_fill);
				NotifyPropertyChanged("Fill");
			}
		}

        double _fontSize = 12;
        public double FontSize
        {
            get
            {
                return _fontSize;
            }
            set
            {
                _fontSize = value;

                if (FontSizeChanged != null)
                    FontSizeChanged(FontSize);
				NotifyPropertyChanged("FontSize");
            }
        }

        FontFamily _fontFamily = new FontFamily("Verdana");
		public FontFamily FontFamily
        {
            get
            {
                return _fontFamily;
            }
            set
            {
                _fontFamily = value;

                if (FontFamilyChanged != null)
                    FontFamilyChanged(FontFamily);
				NotifyPropertyChanged("FontFamily");
            }
        }

		//List<string> _fontFamilies;
		//public List<string> FontFamilies
		//{
		//    get
		//    {
		//        if (_fontFamilies == null)
		//        {
		//            _fontFamilies = new List<string>();
		//            FontFamily
		//        }

		//        return _fontFamilies;
		//    }
		//}

        bool _snapToTrackers = false;
        public bool SnapToTrackers
        {
            get
            {
                return _snapToTrackers;
            }
            set
            {
                _snapToTrackers = value;
				NotifyPropertyChanged("SnapToTrackers");
            }
        }
    
	}
}
